function [F,info] = boWatsonTest(N)
% WATSONTEST - 测试Watson函数
%   输入变量：
%   N  相应的n的数组
%   输出变量：
%   F：最优值数列
%   info：相关info
[stop , n ] =check(N);
if stop, error('x must be a real valued vector'), end

for i = 1:n,
    x0 = zeros(N(i),1);
    x = zeros(N(i),5);
    % 阻尼boNewton法。
    %'damping newton'
    maxstep = 5000;
    opts = [0,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,1),F(i,1),info(:,1,i)]=boNewton(@Watson,x0,opts);
    %'multi boNewton'
    opts = [1,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,2),F(i,2),info(:,2,i)]=boNewton(@Watson,x0,opts);
    %'Quasi boNewton:SR1'
    opts = [2,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,3),F(i,3),info(:,3,i)]=boNewton(@Watson,x0,opts);
    %'Quasi boNewton:BFGS'
    opts = [3,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,4),F(i,4),info(:,4,i)]=boNewton(@Watson,x0,opts);
    %'Quasi boNewton:DFP'              
    opts = [4,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,5),F(i,5),info(:,5,i)]=boNewton(@Watson,x0,opts);
end
end
function [err,n] = check(x)
% CHECK - check x
%   
    err = 0; sx = size(x); n = max(sx);
    if  (min(sx) ~= 1) | ~isreal(x) | any(isnan(x(:))) | isinf(norm(x(:))) 
        err = -1; 
    end    
end
